/*
 * Light.cpp
 *
 *  Created on: 2012/07/05
 *      Author: Weihe
 */

#include "Light.h"
#include <gl/glut.h>

namespace glex {

void Light::setupLight(int lightId) {
		glEnable(lightId);
		glLightfv(lightId, GL_POSITION, position.getArray());
		if (spotCutoff > 100) {
			glLightfv(lightId, GL_SPOT_DIRECTION, direction.getArray());
			glLightf(lightId, GL_SPOT_CUTOFF, spotCutoff);
			glLightf(lightId, GL_SPOT_EXPONENT, spotExponent);
		}
		glLightfv(lightId, GL_SPECULAR, specular.getArray());
		glLightfv(lightId, GL_DIFFUSE, diffuse.getArray());
		glLightfv(lightId, GL_AMBIENT, ambient.getArray());
		glLightf(lightId, GL_CONSTANT_ATTENUATION, constantAttenuation);
		glLightf(lightId, GL_LINEAR_ATTENUATION, linearAttenuation);
		glLightf(lightId, GL_QUADRATIC_ATTENUATION, quadraticAttenuation);
	}

} /* namespace glex */
